#include<stdio.h>

typedef int ITEM;
typedef struct
{
    ITEM data[10];
    int top;
    int count;
    int size;
}Stack;

void initStack(Stack *stack)
{
    assert(stack != NULL);
    memset(stack->data, 0, sizeof(stack->data));
    stack->top = 10;
    stack->size = 10;
}

int getSize(Stack *stack)
{
    assert(stack != NULL);
    return stack->size;
}

int getCount(Stack *stack)
{
    assert(stack != NULL);
    return stack->count;
}

ITEM top(Stack *stack)
{
    assert(stack != NULL);
    return stack->data[top];
}

bool isEmpty(Stack *stack)
{
    assert(stack != NULL);
    return stack->count == 0;
}

bool isFull(Stack *stack)
{
    assert(stack != NULL);
    return stack->count == stack->size;
}

ITEM pop(Stack *stack)
{
    assert(stack != NULL);
    if (isEmpty(stack))
    {
        return -1;
    }
    stack->count--;
    return stack->data[stack->top++];
}

bool push(Stack *stack, ITEM data)
{
    assert(stack != NULL);
    if (isFull(stack))
       return false;
    stack->data[--stack->top] = data;
    stack->count++;
    return true; 
}

int main(void) {
    Stack stack;
    initStack(&stack);
    for(int i=1; i<=10; i++)
    {
        push(&stack, i);
    }
    printf("stack count= %d\n", getCount(&stack));
    for(int i=0; i<10; i++)
    {
        printf("Stack item= %d\n", pop(&stack));
    }
          
    return 0;
}